home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / Components.h < prev    next >
Text File  |  1995-07-06  |  12KB  |  315 lines

  1. /*
  2.      File:        Components.h
  3.  
  4.      Contains:    Component Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __COMPONENTS__
  21. #define __COMPONENTS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MIXEDMODE__
  30. #include <MixedMode.h>
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_ALIGN_SUPPORTED
  38. #pragma options align=mac68k
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT_SUPPORTED
  42. #pragma import on
  43. #endif
  44.  
  45.  
  46. enum {
  47.     kAppleManufacturer            = 'appl',                        /* Apple supplied components */
  48.     kComponentResourceType        = 'thng'
  49. };
  50.  
  51. enum {
  52.     kAnyComponentType            = 0,
  53.     kAnyComponentSubType        = 0,
  54.     kAnyComponentManufacturer    = 0,
  55.     kAnyComponentFlagsMask        = 0
  56. };
  57.  
  58. enum {
  59.     cmpWantsRegisterMessage        = 1L << 31
  60. };
  61.  
  62. enum {
  63.     kComponentOpenSelect        = -1,                            /* ComponentInstance for this open */
  64.     kComponentCloseSelect        = -2,                            /* ComponentInstance for this close */
  65.     kComponentCanDoSelect        = -3,                            /* selector # being queried */
  66.     kComponentVersionSelect        = -4,                            /* no params */
  67.     kComponentRegisterSelect    = -5,                            /* no params */
  68.     kComponentTargetSelect        = -6,                            /* ComponentInstance for top of call chain */
  69.     kComponentUnregisterSelect    = -7                            /* no params */
  70. };
  71.  
  72. /* Component Resource Extension flags */
  73. enum {
  74.     componentDoAutoVersion        = (1 << 0),
  75.     componentWantsUnregister    = (1 << 1),
  76.     componentAutoVersionIncludeFlags = (1 << 2),
  77.     componentHasMultiplePlatforms = (1 << 3)
  78. };
  79.  
  80. /* Set Default Component flags */
  81. enum {
  82.     defaultComponentIdentical    = 0,
  83.     defaultComponentAnyFlags    = 1,
  84.     defaultComponentAnyManufacturer = 2,
  85.     defaultComponentAnySubType    = 4,
  86.     defaultComponentAnyFlagsAnyManufacturer = (defaultComponentAnyFlags + defaultComponentAnyManufacturer),
  87.     defaultComponentAnyFlagsAnyManufacturerAnySubType = (defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType)
  88. };
  89.  
  90. /* RegisterComponentResource flags */
  91. enum {
  92.     registerComponentGlobal        = 1,
  93.     registerComponentNoDuplicates = 2,
  94.     registerComponentAfterExisting = 4
  95. };
  96.  
  97. struct ComponentDescription {
  98.     OSType                            componentType;                /* A unique 4-byte code indentifying the command set */
  99.     OSType                            componentSubType;            /* Particular flavor of this instance */
  100.     OSType                            componentManufacturer;        /* Vendor indentification */
  101.     unsigned long                    componentFlags;                /* 8 each for Component,Type,SubType,Manuf/revision */
  102.     unsigned long                    componentFlagsMask;            /* Mask for specifying which flags to consider in search, zero during registration */
  103. };
  104. typedef struct ComponentDescription ComponentDescription;
  105.  
  106. struct ResourceSpec {
  107.     OSType                            resType;                    /* 4-byte code  */
  108.     short                            resID;
  109. };
  110. typedef struct ResourceSpec ResourceSpec;
  111.  
  112. struct ComponentResource {
  113.     ComponentDescription            cd;                            /* Registration parameters */
  114.     ResourceSpec                    component;                    /* resource where Component code is found */
  115.     ResourceSpec                    componentName;                /* name string resource */
  116.     ResourceSpec                    componentInfo;                /* info string resource */
  117.     ResourceSpec                    componentIcon;                /* icon resource */
  118. };
  119. typedef struct ComponentResource ComponentResource;
  120.  
  121. typedef ComponentResource *ComponentResourcePtr, **ComponentResourceHandle;
  122.  
  123. struct ComponentPlatformInfo {
  124.     long                            componentFlags;                /* flags of Component */
  125.     ResourceSpec                    component;                    /* resource where Component code is found */
  126.     short                            platformType;                /* gestaltSysArchitecture result */
  127. };
  128. typedef struct ComponentPlatformInfo ComponentPlatformInfo;
  129.  
  130. struct ComponentResourceExtension {
  131.     long                            componentVersion;            /* version of Component */
  132.     long                            componentRegisterFlags;        /* flags for registration */
  133.     short                            componentIconFamily;        /* resource id of Icon Family */
  134. };
  135. typedef struct ComponentResourceExtension ComponentResourceExtension;
  136.  
  137. struct ComponentPlatformInfoArray {
  138.     long                            count;
  139.     ComponentPlatformInfo            platformArray[1];
  140. };
  141. typedef struct ComponentPlatformInfoArray ComponentPlatformInfoArray;
  142.  
  143. struct ExtComponentResource {
  144.     ComponentDescription            cd;                            /* registration parameters */
  145.     ResourceSpec                    component;                    /* resource where Component code is found */
  146.     ResourceSpec                    componentName;                /* name string resource */
  147.     ResourceSpec                    componentInfo;                /* info string resource */
  148.     ResourceSpec                    componentIcon;                /* icon resource */
  149.     long                            componentVersion;            /* version of Component */
  150.     long                            componentRegisterFlags;        /* flags for registration */
  151.     short                            componentIconFamily;        /* resource id of Icon Family */
  152.     long                            count;                        /* elements in platformArray */
  153.     ComponentPlatformInfo            platformArray[1];
  154. };
  155. typedef struct ExtComponentResource ExtComponentResource;
  156.  
  157. struct ComponentParameters {
  158.     unsigned char                    flags;                        /* call modifiers: sync/async, deferred, immed, etc */
  159.     unsigned char                    paramSize;                    /* size in bytes of actual parameters passed to this call */
  160.     short                            what;                        /* routine selector, negative for Component management calls */
  161.     long                            params[1];                    /* actual parameters for the indicated routine */
  162. };
  163. typedef struct ComponentParameters ComponentParameters;
  164.  
  165. struct ComponentRecord {
  166.     long                            data[1];
  167. };
  168. typedef struct ComponentRecord ComponentRecord;
  169.  
  170. typedef ComponentRecord *Component;
  171.  
  172. struct ComponentInstanceRecord {
  173.     long                            data[1];
  174. };
  175. typedef struct ComponentInstanceRecord ComponentInstanceRecord;
  176.  
  177. typedef ComponentInstanceRecord *ComponentInstance;
  178.  
  179. typedef long ComponentResult;
  180.  
  181. typedef pascal ComponentResult (*ComponentRoutineProcPtr)(ComponentParameters *cp, Handle componentStorage);
  182.  
  183. #if GENERATINGCFM
  184. typedef UniversalProcPtr ComponentRoutineUPP;
  185. #else
  186. typedef ComponentRoutineProcPtr ComponentRoutineUPP;
  187. #endif
  188.  
  189. enum {
  190.     uppComponentRoutineProcInfo = kPascalStackBased
  191.          | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  192.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentParameters*)))
  193.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
  194. };
  195.  
  196. #if GENERATINGCFM
  197. #define NewComponentRoutineProc(userRoutine)        \
  198.         (ComponentRoutineUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppComponentRoutineProcInfo, GetCurrentArchitecture())
  199. #else
  200. #define NewComponentRoutineProc(userRoutine)        \
  201.         ((ComponentRoutineUPP) (userRoutine))
  202. #endif
  203.  
  204. #if GENERATINGCFM
  205. #define CallComponentRoutineProc(userRoutine, cp, componentStorage)        \
  206.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppComponentRoutineProcInfo, (cp), (componentStorage))
  207. #else
  208. #define CallComponentRoutineProc(userRoutine, cp, componentStorage)        \
  209.         (*(userRoutine))((cp), (componentStorage))
  210. #endif
  211.  
  212. typedef ComponentRoutineProcPtr ComponentRoutine;
  213.  
  214. /*
  215.     The parameter list for each ComponentFunction is unique. It is 
  216.     therefore up to users to create the appropriate procInfo for their 
  217.     own ComponentFunctions where necessary.
  218. */
  219. typedef UniversalProcPtr ComponentFunctionUPP;
  220.  
  221. #if CFMSYSTEMCALLS
  222. /* 
  223.     CallComponentUPP is a global variable exported from InterfaceLib.
  224.     It is the ProcPtr passed to CallUniversalProc to manually call a component function.
  225. */
  226. extern UniversalProcPtr CallComponentUPP;
  227.  
  228. #endif
  229. #define ComponentCallNow( callNumber, paramSize ) \
  230.     FIVEWORDINLINE( 0x2F3C,paramSize,callNumber,0x7000,0xA82A )
  231.  
  232. extern pascal Component RegisterComponent(ComponentDescription *cd, ComponentRoutineUPP componentEntryPoint, short global, Handle componentName, Handle componentInfo, Handle componentIcon)
  233.  TWOWORDINLINE(0x7001, 0xA82A);
  234. extern pascal Component RegisterComponentResource(ComponentResourceHandle tr, short global)
  235.  TWOWORDINLINE(0x7012, 0xA82A);
  236. extern pascal OSErr UnregisterComponent(Component aComponent)
  237.  TWOWORDINLINE(0x7002, 0xA82A);
  238. extern pascal Component FindNextComponent(Component aComponent, ComponentDescription *looking)
  239.  TWOWORDINLINE(0x7004, 0xA82A);
  240. extern pascal long CountComponents(ComponentDescription *looking)
  241.  TWOWORDINLINE(0x7003, 0xA82A);
  242. extern pascal OSErr GetComponentInfo(Component aComponent, ComponentDescription *cd, Handle componentName, Handle componentInfo, Handle componentIcon)
  243.  TWOWORDINLINE(0x7005, 0xA82A);
  244. extern pascal long GetComponentListModSeed(void)
  245.  TWOWORDINLINE(0x7006, 0xA82A);
  246. /* Component Instance Allocation and dispatch routines */
  247. extern pascal ComponentInstance OpenComponent(Component aComponent)
  248.  TWOWORDINLINE(0x7007, 0xA82A);
  249. extern pascal OSErr CloseComponent(ComponentInstance aComponentInstance)
  250.  TWOWORDINLINE(0x7008, 0xA82A);
  251. extern pascal OSErr GetComponentInstanceError(ComponentInstance aComponentInstance)
  252.  TWOWORDINLINE(0x700A, 0xA82A);
  253. /* Direct calls to the Components */
  254. extern pascal long ComponentFunctionImplemented(ComponentInstance ci, short ftnNumber)
  255.  FIVEWORDINLINE(0x2F3C, 0x2, 0xFFFD, 0x7000, 0xA82A);
  256. extern pascal long GetComponentVersion(ComponentInstance ci)
  257.  FIVEWORDINLINE(0x2F3C, 0x0, 0xFFFC, 0x7000, 0xA82A);
  258. extern pascal long ComponentSetTarget(ComponentInstance ci, ComponentInstance target)
  259.  FIVEWORDINLINE(0x2F3C, 0x4, 0xFFFA, 0x7000, 0xA82A);
  260. /* Component Management routines */
  261. extern pascal void SetComponentInstanceError(ComponentInstance aComponentInstance, OSErr theError)
  262.  TWOWORDINLINE(0x700B, 0xA82A);
  263. extern pascal long GetComponentRefcon(Component aComponent)
  264.  TWOWORDINLINE(0x7010, 0xA82A);
  265. extern pascal void SetComponentRefcon(Component aComponent, long theRefcon)
  266.  TWOWORDINLINE(0x7011, 0xA82A);
  267. extern pascal short OpenComponentResFile(Component aComponent)
  268.  TWOWORDINLINE(0x7015, 0xA82A);
  269. extern pascal OSErr CloseComponentResFile(short refnum)
  270.  TWOWORDINLINE(0x7018, 0xA82A);
  271. /* Component Instance Management routines */
  272. extern pascal Handle GetComponentInstanceStorage(ComponentInstance aComponentInstance)
  273.  TWOWORDINLINE(0x700C, 0xA82A);
  274. extern pascal void SetComponentInstanceStorage(ComponentInstance aComponentInstance, Handle theStorage)
  275.  TWOWORDINLINE(0x700D, 0xA82A);
  276. extern pascal long GetComponentInstanceA5(ComponentInstance aComponentInstance)
  277.  TWOWORDINLINE(0x700E, 0xA82A);
  278. extern pascal void SetComponentInstanceA5(ComponentInstance aComponentInstance, long theA5)
  279.  TWOWORDINLINE(0x700F, 0xA82A);
  280. extern pascal long CountComponentInstances(Component aComponent)
  281.  TWOWORDINLINE(0x7013, 0xA82A);
  282. /* Useful helper routines for convenient method dispatching */
  283. extern pascal long CallComponentFunction(ComponentParameters *params, ComponentFunctionUPP func)
  284.  TWOWORDINLINE(0x70FF, 0xA82A);
  285. extern pascal long CallComponentFunctionWithStorage(Handle storage, ComponentParameters *params, ComponentFunctionUPP func)
  286.  TWOWORDINLINE(0x70FF, 0xA82A);
  287. extern pascal long DelegateComponentCall(ComponentParameters *originalParams, ComponentInstance ci)
  288.  TWOWORDINLINE(0x7024, 0xA82A);
  289. extern pascal OSErr SetDefaultComponent(Component aComponent, short flags)
  290.  TWOWORDINLINE(0x701E, 0xA82A);
  291. extern pascal ComponentInstance OpenDefaultComponent(OSType componentType, OSType componentSubType)
  292.  TWOWORDINLINE(0x7021, 0xA82A);
  293. extern pascal Component CaptureComponent(Component capturedComponent, Component capturingComponent)
  294.  TWOWORDINLINE(0x701C, 0xA82A);
  295. extern pascal OSErr UncaptureComponent(Component aComponent)
  296.  TWOWORDINLINE(0x701D, 0xA82A);
  297. extern pascal long RegisterComponentResourceFile(short resRefNum, short global)
  298.  TWOWORDINLINE(0x7014, 0xA82A);
  299. extern pascal OSErr GetComponentIconSuite(Component aComponent, Handle *iconSuite)
  300.  TWOWORDINLINE(0x7029, 0xA82A);
  301.  
  302. #if PRAGMA_IMPORT_SUPPORTED
  303. #pragma import off
  304. #endif
  305.  
  306. #if PRAGMA_ALIGN_SUPPORTED
  307. #pragma options align=reset
  308. #endif
  309.  
  310. #ifdef __cplusplus
  311. }
  312. #endif
  313.  
  314. #endif /* __COMPONENTS__ */
  315.